package cn.com.liuxiaoluxx.cloud.api.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * The type IntelliJ IDEA.
 * <p>
 *
 * @author liuxiaolu
 * @date 2020/9/17
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class RestResult<T> {

    private int code;
    private String msg;
    private T value;

    public static <T> RestResult<T> ok() {
        return ok(null);
    }

    public static <T> RestResult<T> ok(T data) {
        return new RestResult<>(200, "", data);
    }

    public static <T> RestResult<T> failure(String msg) {
        return new RestResult<>(500, msg, null);
    }

    public static <T> RestResult<T> failure(int code, String msg) {
        return new RestResult<>(code, msg, null);
    }
}
